import {axios} from "../../utils/request"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    initData:[]
  },
  getContext(e:any){
    let item = e.currentTarget.dataset.item
    wx.navigateTo({
      url: '/pages/context/context',
      success:(res)=> {
        // 通过 eventChannel 向被打开页面传送数据
        res.eventChannel.emit('contextData', { data: this.data.initData[item],isStart:true})
      }
    })
  },
  async start(e:any){
    const id = e.currentTarget.dataset.id
   
  },
  /**
   * 生命周期函数--监听页面显示
   */
  async onShow() {
    const { data } = await axios("/start") as any
    const reultList =  data.data.map((item:any)=>{
      item.createTime = item.createTime.slice(0,10)
      item.cover = item.pics[0].url
      return item
    })
    this.setData({
      initData:reultList
    })
  }
})